<template>
  <div class="header wrap">
    <!-- logo -->
    <div class="logo">
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </div>
    <!-- 导航 -->
    <ul class="header-nav">
      <li
        :class="{ active: $route.path === '/home' }"
        @click="$router.push('/home')"
      >
        首页
      </li>
      <li
        :class="{ active: $route.path === '/goods' }"
        @click="$router.push('/goods')"
      >
        全部商品
      </li>
      <li
        :class="{ active: $route.path === '/user' }"
        @click="$router.push('/user')"
      >
        个人中心
      </li>
      <li
        :class="{ active: $route.path === '/order' }"
        @click="$router.push('/order')"
      >
        壁纸合集
      </li>
      <li
        :class="{ active: $route.path === '/free' }"
        @click="$router.push('/free')"
      >
        专属福利
      </li>
    </ul>
    <!-- 搜索框 -->
    <div class="search">
      <input type="text" placeholder="输入关键字" v-model="userinput" />
      <span @click="searchFn">
        <img src="../assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userinput: "",
    };
  },
  methods: {
    searchFn() {
      // console.log(this.userinput);
      // 跳转到good.vue
      this.$router.push(`/goods?keyword=${this.userinput}`);
      this.userinput = "";
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-family: SourceHanSansSC;
  font-weight: 500;

  .logo {
    cursor: pointer;
  }

  .header-nav {
    display: flex;
    width: 500px;
    justify-content: space-between;

    li {
      cursor: pointer;
    }

    .active {
      color: #0a328e;
    }
  }

  .search {
    display: flex;

    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      padding: 19px;
      outline: none;
    }

    span {
      width: 50px;
      height: 40px;
      line-height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      display: inline-block;
      text-align: center;
      cursor: pointer;

      img {
        vertical-align: middle;
      }
    }
  }
}
</style>